/**
 * Created by Administrator on 14-2-10.
 */
var mongoose = require('mongoose');
var timestamps = require('mongoose-timestamp');//(给Model自动添加createdAt和updatedAt):

var Schema = mongoose.Schema,
    ObjectId = Schema.ObjectId;

//	分类
var schema_type = new Schema({
    category:Number,
    type_index:Number
},{_id:false,versionKey:false});

// “可替换模版的页“的信息
var schema_rel_pages_info = new Schema({
    page_id:Number,
    weight:Number,
},{_id:false,versionKey:false});

// “模版的页“与“可替换模版的页“的对应关系
var schema_rel_map = new Schema({
    page_id:Number,
    rel_pages:[schema_rel_pages_info]
},{_id:false,versionKey:false});

// “模版“与所有“可替换模版“的对应关系
var schema_rel_tmpl_info = new Schema({
    rel_tmpl_id:Number,
    maps:[schema_rel_map]
},{_id:false,versionKey:false});

// Schema 结构
var schema = new Schema({
    // _id:ObjectId, // default id
    tmpl_id:Number,     // 模板的id
    type:[schema_type], //	分类的数组
    rel_tmpl_info:[schema_rel_tmpl_info], // 可替换模版的数组
});
schema.plugin(timestamps);

mongoose.model('MRelTmplInfoModel', schema, 'MRelTmplInfo');
